package com.itheima.demo5;

import java.io.*;
import java.nio.charset.Charset;

public class IODemo10 {
    public static void main(String[] args) throws IOException {
/*
        //创建对象并指定字符编码
        InputStreamReader gbk = new InputStreamReader(new FileInputStream("a.txt"), "GBK");

        //读取数据
        int ch;
        while ((ch = gbk.read()) != -1){
            System.out.println((char)ch);
        }

        gbk.close();*/

        FileReader gbk = new FileReader("a.txt", Charset.forName("GBK"));

        //读取数据
        int ch;
        while ((ch = gbk.read()) != -1){
            System.out.println((char)ch);
        }

        gbk.close();

    }
}
